﻿#region COPYRIGHT
//--------------------------------------------------------------------------------
// <copyright file="ToolStripMenuItem.cs" company="starLiGHT Entertainment Studios">
//    Copyright (c) 2011 
//       Roland Rosenkranz (Glatzemann@email.de)
// </copyright>
// <license>
//   This file is part of starLiGHT.GUI.
//
//   It is released under the Microsoft Public License (Ms-PL).
//
//   You should have received a copy of the Microsoft Public License
//   along with starLiGHT.GUI. If not, see http://sle.codeplex.com/license.
//    
//   ADDITIONAL (commercial) LICENSES for starLiGHT.GUI are available on request.
// </license>
// <version>
// **************[ starLiGHT.Engine SVN ]**********************
// * $Rev:: 9926                  $:  Revision of last commit *
// * $Author:: unknown            $:  Author of last commit   *
// * $Date:: 2011-05-10 19:07:29 #$:  Date of last commit     *
// ************************************************************
// </version>
//--------------------------------------------------------------------------------
#endregion

namespace starLiGHT.GUI.Widgets
{
    #region Using Statements
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;
    #endregion

    public class ToolStripMenuItem : ToolStripDropDownItem
    {
        public override void Draw(GameTime gameTime, IGuiRenderer renderer, ToolStrip toolStrip, ref Vector2 offset)
        {
            Vector2 itemSize = Vector2.Zero;
            itemSize = toolStrip.Manager.DefaultFont.MeasureString(Text);
            renderer.DrawString(toolStrip.Manager.DefaultFont, Text, offset, Focus ? Color.Yellow : toolStrip.ForeColor);
            offset.X += itemSize.X;

            ////TODO: render backdrop
            if (((MenuStrip)toolStrip).MenuExpanded && Focus && DropDownItems.Count > 0)
            {
                // render sub-menu's
                foreach (ToolStripItem tsmi in DropDownItems)
                {
                    Vector2 subItemPosition = tsmi.Offset;
                    tsmi.Draw(gameTime, renderer, toolStrip, ref subItemPosition);
                }
            }
        }
    }
}
